package com.dkd.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.manage.domain.Parties;
import com.dkd.manage.service.IPartiesService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 资产组件Controller
 *
 * @author zqy
 * @date 2024-12-25
 */
@Api(tags = "资产组件Controller")
@RestController
@RequestMapping("/manage/parties")
public class PartiesController extends BaseController
{
    @Autowired
    private IPartiesService partiesService;

/**
 * 查询资产组件列表
 */
@ApiOperation("查询资产组件列表")
@PreAuthorize("@ss.hasPermi('manage:parties:list')")
@GetMapping("/list")
    public TableDataInfo list(Parties parties)
    {
        startPage();
        List<Parties> list = partiesService.selectPartiesList(parties);
        return getDataTable(list);
    }

    /**
     * 导出资产组件列表
     */
    @ApiOperation("导出资产组件列表")
    @PreAuthorize("@ss.hasPermi('manage:parties:export')")
    @Log(title = "资产组件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Parties parties)
    {
        List<Parties> list = partiesService.selectPartiesList(parties);
        ExcelUtil<Parties> util = new ExcelUtil<Parties>(Parties.class);
        util.exportExcel(response, list, "资产组件数据");
    }

    /**
     * 获取资产组件详细信息
     */
    @ApiOperation("获取资产组件详细信息")
    @PreAuthorize("@ss.hasPermi('manage:parties:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(partiesService.selectPartiesById(id));
    }

    /**
     * 新增资产组件
     */
    @ApiOperation("新增资产组件")
    @PreAuthorize("@ss.hasPermi('manage:parties:add')")
    @Log(title = "资产组件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Parties parties)
    {
        return toAjax(partiesService.insertParties(parties));
    }

    /**
     * 修改资产组件
     */
    @ApiOperation("修改资产组件")
    @PreAuthorize("@ss.hasPermi('manage:parties:edit')")
    @Log(title = "资产组件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Parties parties)
    {
        return toAjax(partiesService.updateParties(parties));
    }

    /**
     * 删除资产组件
     */
    @ApiOperation("删除改资产组件")
    @PreAuthorize("@ss.hasPermi('manage:parties:remove')")
    @Log(title = "资产组件", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(partiesService.deletePartiesByIds(ids));
    }
}
